package com.qf.web;

import com.qf.pojo.Category;
import com.qf.service.CategoryService;
import com.qf.service.serviceimpl.CategoryServiceImpl;
import com.qf.utils.JsonUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/category")
public class CategoryServlet extends BaseServlet {
    public void findMenu(HttpServletRequest request,HttpServletResponse response)
            throws ServletException, IOException {
        /**
         *查找所有分类信息
         */
        CategoryService cs = new CategoryServiceImpl();
        List<Category> list = cs.findAllCategory();
        //System.out.println(list);
       /* request.setAttribute("list",list);
        //请求转发到首页
        request.getRequestDispatcher("/jsp/index.jsp").forward(request,response);*/
        String json = JsonUtils.list2json(list);
        //System.out.println(json);
        response.getWriter().write(json);
    }
}
